package view;


import java.awt.*;
import javax.swing.*;
import model.*;
import java.awt.event.*;
import java.io.FileNotFoundException;
import java.util.ArrayList;

//Jun: This is just a test. I'm trying to figure out how to actually code the view.
//For a title screen, gameplay screen, directions screen, the prof suggested we create
//a single Frame and multiple JPanels each type of screen. Based on user input, we would
//display the appropriate JPanel. A Frame is just the window from what I understand. But
//I'm still trying to figure it out.

public class froggerView extends JFrame {

    
	private static final long serialVersionUID = 7632650284490142197L;
	
	//... Components
    private JButton m_pauseBtn = new JButton("Pause");
    private JButton m_quitBtn = new JButton("Quit");
    private JLabel label = new JLabel("this is a label");
    private gameModelI m_model;
    
    class gamePanel extends JPanel {
		public gamePanel() {
			setBackground(Color.white);
			setLayout(new FlowLayout());
			setPreferredSize(new Dimension(1000, 600));
			add(m_pauseBtn);
			add(m_quitBtn);
			add(label);
			
		}
	    
    public void paint(Graphics g){
    	super.paintComponent(g);
    	g.setColor(Color.black);
    	ArrayList<log> list = m_model.getLogs();
    	for (int i = 0; i < list.size(); i++) {
    		g.drawRect(list.get(i).getPosX(), list.get(i).getPosY(), list.get(i).getWidth(), list.get(i).getHeight());
            g.drawString(list.get(i).getWord(), list.get(i).getPosX()+20, list.get(i).getPosY()+20);
    	}
    	
    }
    }
    
    public froggerView() throws FileNotFoundException {
    	super("Frogger Test - MVC");
        m_model = new gameModel();
               
        //this.setContentPane(content);
		pack();
		setVisible(true);
        
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setLayout(new BorderLayout());
		
		JPanel game = new gamePanel(); //create the gamePanel
		
		add(game, BorderLayout.CENTER);
		
		// The JFrame will choose its initial size
		// based on its content.
		pack();
		setVisible(true);
    }
    
    void addPauseListener(ActionListener e) {
        m_pauseBtn.addActionListener(e);
    }
    
    void addQuitListener(ActionListener e) {
        m_quitBtn.addActionListener(e);
    }
}